package com.xizimall.order.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
/**
 * 订单Controller
 * <p>Title: OrderController</p>
 * <p>Description: </p>
 * <p>华南理工大学研究生</p> 
 * @author	李隆熹
 * @date	2018年5月2日下午4:07:19
 * @version 1.0
 */
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xizimall.order.pojo.Order;
import com.xizimall.order.service.OrderService;
import com.xizimall.common.pojo.XizimallResult;
import com.xizimall.common.utils.ExceptionUtil;
@Controller
public class OrderController {
     @Autowired
     private OrderService orderService;
     
     @RequestMapping(value="/create",method=RequestMethod.POST)
     @ResponseBody
     public XizimallResult createOrder(@RequestBody Order order){
    	 try {
    		 XizimallResult result = orderService.createOrder(order, order.getOrderItems(), order.getOrderShipping());
        	 return result;
		} catch (Exception e) {
			e.printStackTrace();
			return XizimallResult.build(500, ExceptionUtil.getStackTrace(e));
		}
     }
}
